package com.itcam.enum_;

/**
 * Author:Cammy.Wu
 * Date:2024-04-27
 * Description:测试自定义枚举类
 */

public class SeasonTest {
    public static void main(String[] args) {
        Season spring = Season.SPRING;
        System.out.println("spring = " + spring);
        System.out.println(Season.class.getSuperclass().getName());

        Season_enum summer = Season_enum.SUMMER;
        System.out.println("spring_enum = " + summer);
        System.out.println(Season_enum.class.getSuperclass().getName());

        /**
         * 自定义的枚举类的上层父类是：java.lang.Object
         * enum关键字对应的枚举类的上层父类是：java.lang.Enum
         */

        //——————————————————————————————————————————————————————————————————————————————

        //用enum关键字创建的Season枚举类上面的父类是：java.lang.Enum，常用方法子类Season可以直接拿过来使用
        Season_enum_brief autumn = Season_enum_brief.AUTUMN;
        System.out.println("autumn = " + autumn/*.toString()*/);


        // values 返回枚举类对象的数组
        Season_enum_brief[] values = Season_enum_brief.values();
        for (Season_enum_brief s : values) {
            System.out.println("s = " + s);
        }

        // valueOf
        // valueOf:通过对象名字获取这个枚举对象
        // 注意：对象的名字必须传正确，否则抛出异常
        Season_enum_brief winter=Season_enum_brief.valueOf("WINTER");
        System.out.println("winter = " + winter);

        //——————————————————————————————————————————————————————————————————————————————

        Season_enum_Impl enum_ = Season_enum_Impl.SPRING;
        enum_.show();

        //——————————————————————————————————————————————————————————————————————————————

        Person person = new Person();
        person.setName("姬如雪");
        person.setAge(24);
        person.setSex(Gender.女);

        System.out.println(person);

        //——————————————————————————————————————————————————————————————————————————————

        Gender sex = Gender.男;
        switch (sex){
            case 女 :
                System.out.println("找个男人");
                break;
            case 男:
                System.out.println("找个女人");
                break;
        }
    }
}
